package spr.lime.lmAdm.validator.login;



import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import spr.lime.lmAdm.model.login.AdmMemberModel;

public class AdmLoginValidator implements Validator{
	
	
	@Override
	public boolean supports(Class<?> clazz) {
		return AdmMemberModel.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		AdmMemberModel loginModel = (AdmMemberModel) target;
		
		// check userId field
		if(loginModel.getMe_uid() == null || loginModel.getMe_uid().trim().isEmpty()) {
			errors.rejectValue("me_uid", "required_id");
		}
		
		// check userPw field
		if(loginModel.getMe_pwd() == null || loginModel.getMe_pwd().trim().isEmpty()){
			errors.rejectValue("me_pwd", "required_pwd");
		} 

	}
}
